package edu.sctu.practice.class02.hujie.cgs.assign02s;

import javax.swing.*;

/**
 * Created by hp on 2015/12/24.
 */
public class Number {
    public static void main(String[] args) {
        int number = 0, d5, d4, d3, d2, d1;
        String str = JOptionPane.showInputDialog("输入一个1至99999之间的数");
        number=Integer.parseInt(str);
        if (number>1&&number<99999){
            d5=number/10000;
            d4=(number-d5*10000)/1000;
            d3=(number-d5*10000-d4*1000)/100;
            d2=(number-d5*10000-d4*1000-d3*100)/10;
            d1=number-d5*10000-d4*1000-d3*100-d2*10;
            if (number%10000>0){
                System.out.println(number+"是5位数！");
                if (d5==d1&&d4==d2){
                    System.out.println(number+"是回文数");
                }else {
                    System.out.println(number+"不是回文数！");
                }
            }else if (number%1000>0){
                System.out.println(number+"是4位数");
                if (d4==d1&&d3==d2){
                    System.out.println(number+"是回文数");
                }else {
                    System.out.println(number+"不是回文数");
                }
            }else if (number%100>0){
                System.out.println(number+"是3位数");
                if (d3==d1){
                    System.out.println(number+"是回文数");
                }else {
                    System.out.println(number+"不是回文数");
                }
            }else if (number%10>0){
                System.out.println(number+"是2位数");
                if (d2==d1){
                    System.out.println(number+"是回文数");
                }else {
                    System.out.println(number+"不是回文数");
                }
            }
        }else {
            System.out.println("\n%d不在1至99999之间，"+number);
        }
    }
}